package com.ysu.his.admin.controller;

import com.ysu.his.admin.service.LoginOutService;
import com.ysu.his.admin.service.ValidateCodeService;
import com.ysu.his.dto.LoginDto;
import com.ysu.his.vo.LoginVo;
import com.ysu.his.vo.ValidateCodeVo;
import com.ysu.his.vo.common.Result;
import com.ysu.his.vo.common.ResultCodeEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/admin")
public class LoginOutController
{
    @Autowired
    private LoginOutService loginOutService;

    @Autowired
    private ValidateCodeService validateCodeService;

    @PostMapping(value = "/login")
    public Result login(@RequestBody LoginDto loginDto)
    {
        LoginVo loginVo = loginOutService.login(loginDto);
        return Result.ok(loginVo);
    }

    @GetMapping(value = "/logout")
    public Result logout()
    {
        return Result.ok(null);
    }

    @GetMapping(value = "/generateValidateCode")
    public Result generateValidateCode()
    {
        ValidateCodeVo validateCodeVo = validateCodeService.generateValidateCode();
        return Result.ok(validateCodeVo);
    }
}
